﻿CREATE PROCEDURE [dbo].[uspt_ip_create_or_update_sns]
    @id UNIQUEIDENTIFIER,
    @login_name VARCHAR(64),
    @login_password VARCHAR(64),
    @nickname NVARCHAR(64)
AS
    IF NOT EXISTS (SELECT 1 FROM tt_ip_sns WHERE [id] = @id)
    BEGIN
        INSERT tt_ip_sns([id], [login_name], [login_password], [nickname])
        VALUES (@id, @login_name, @login_password, @nickname)
    END
    ELSE
    BEGIN
        UPDATE tt_ip_sns SET [login_name] = @login_name, [login_password] = @login_password, [nickname] = @nickname
        WHERE [id] = @id AND ([login_name] <> @login_name OR [login_password] <> @login_password OR [nickname] <> @nickname)
    END
RETURN 0
